import type { SysMenuVO } from "../sysMenu/sysMenuType";
import type { IdDTO, SysBaseVO } from "../type/baseType";

/**
 * 用户搜索筛选
 */
export interface SysUserFiltDTO {
    username?: string
    topDeptId?: string
    nickName?: string
    isDisabled?: number
}

/**
 * 用户编辑类型
 */
export interface SysUserDTO extends IdDTO {
    username: string
    password?: string
    nickName: string
    avatar?: string
    deptId: string
    roleIds: string[]
    isDisabled: number
}

/**
 * 获取用户权限信息响应数据
 */
export interface SysUserAuthInfo extends SysBaseVO {
    username: string
    nickName: string
    avatar: string
    deptId: string
    menus: SysMenuVO[]
    permissions: string[]
    isDisabled: number
}

/**
 * 用户类型
 */
export interface SysUserVO extends SysBaseVO {
    username: string
    nickName: string
    avatar: string
    deptId: string
    roleIds: string[]
    isDisabled: number
}

/**
 * 用户VO转用户DTO
 * @param sysUserVO 
 * @param password 
 * @returns 
 */
export const sysUserVOToDTO = (sysUserVO: SysUserVO, password?: string): SysUserDTO => {
    return {
        username: sysUserVO.username,
        password: password,
        nickName: sysUserVO.nickName,
        avatar: sysUserVO.avatar,
        deptId: sysUserVO.deptId,
        roleIds: sysUserVO.roleIds,
        isDisabled: sysUserVO.isDisabled
    }
}